﻿using CPPEI.Coolzon.Event.NCL;
using CPPEI.Coolzon.Event.UI;
using CPPEI.Coolzon.UI.Event;
using CPPEI.Coolzon.UI.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace CPPEI.Coolzon.Theme.Fashion.MainViewControl
{
    public partial class ZoomView
    {
        /// <summary>
        /// 场景动画事件
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void SceneVewUpdated(AnimationEndEvent @event)
        {
            SetSceneView();
        }
        /// <summary>
        /// 场景交换事件
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void SwapAreaCompleted(SwapAreaCompletedEvent @event)
        {
            SetSceneView();

            partImageSource = GetImageSource();
        }
        /// <summary>
        /// 启动放大镜
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void OnStartMagnifier(UIShowMagnifierEvent @event)
        {
            if (@event.IsEnable)
            {
                if (_interactiveType == UIInteractiveType.ShowLaserPoint)
                {
                    NCLEventBus.PublishAsync(new NCLShowLaserPointerEvent(false, _Scene.Name, 0, 0, 0, 0, 0));
                }
                _interactiveType = UIInteractiveType.ShowMagnifier;
                ResetInteractivePoint();
            }
            else
            {
                if (_interactiveType == UIInteractiveType.ShowMagnifier)
                {
                    _interactiveType = UIInteractiveType.None;
                    NCLEventBus.PublishAsync(new NCLShowMagnifierEvent(false, _Scene.Name, 0, 0, 0, 0, 0));
                }
            }
        }
        /// <summary>
        /// 启动激光笔
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void OnStartPen(UIShowLaserPointEvent @event)
        {
            if (@event.IsEnable)
            {
                if (_interactiveType == UIInteractiveType.ShowMagnifier)
                {
                    NCLEventBus.PublishAsync(new NCLShowMagnifierEvent(false, _Scene.Name, 0, 0, 0, 0, 0));
                }
                _interactiveType = UIInteractiveType.ShowLaserPoint;
                ResetInteractivePoint();
            }
            else
            {
                if (_interactiveType == UIInteractiveType.ShowLaserPoint)
                {
                    _interactiveType = UIInteractiveType.None;
                    NCLEventBus.PublishAsync(new NCLShowLaserPointerEvent(false, _Scene.Name, 0, 0, 0, 0, 0));
                }
            }
        }
        /// <summary>
        /// 场景更新事件
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void SceneUpdated(SceneUpdateEvent @event)
        {
            if (@event.Reason == SceneUpdateReason.Open)
            {
                SetSceneView();
            }
            else if (@event.Reason == SceneUpdateReason.ResetScene)
            {
                AddLine();

                _isResetScene = true;
                UIEventBus.Publish(new UIShowMagnifierEvent(false));
                ShowPen(false);

                UIEventBus.Publish(new UIShowLaserPointEvent(false));
                ShowMagnifier(false);
            }
        }
    }
}
